package com.assignwork.modules.workarrange;

import com.assignwork.dto.WorkArrangeLandSearchDTO;
import com.assignwork.dto.WorkArrangeLandSubmitDTO;
import com.assignwork.service.IWorkArrangeLandService;
import com.assignwork.vo.WorkArrangeLandListVO;
import com.assignwork.vo.WorkArrangeLandPageVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName WorkArrangeLandController
 * @Description 陆运配工前端控制器
 * @Author dujianyu
 * @Date 2023/12/18 8:54
 */
@RestController
@AllArgsConstructor
@RequestMapping("workArrange/land")
public class WorkArrangeLandController extends BladeController {

    private IWorkArrangeLandService service;

    @PostMapping("submit")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "新增或修改", notes = "传入dto")
    public R<Boolean> submitWALand(@RequestBody WorkArrangeLandSubmitDTO dto) {
        return R.status(service.submitWaLand(dto));
    }

    @GetMapping("/page")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "分页", notes = "传入dto")
    public R<WorkArrangeLandPageVO> waLandPage(WorkArrangeLandSearchDTO dto, Query query) {
        return R.data(service.selectWaLandPage(dto, Condition.getPage(query)));
    }

    @PostMapping("/remove")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "删除", notes = "传入id")
    public R<Boolean> remove(@ApiParam(value = "主键集合", required = true) @RequestParam String id) {
        return R.status(service.removeWaLand(Func.toLong(id)));
    }

    @PostMapping("/importFromPrevious")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "从之前导入", notes = "传入dto")
    public R<Boolean> importFromPrevious(@RequestBody WorkArrangeLandSearchDTO dto) {
        return R.status(service.importFromPrevious(dto));
    }

}
